//
//  SearchViewController.m
//  OurMenu
//
//  Created by 尹坤 on 15/10/10.
//  Copyright © 2015年 尹坤. All rights reserved.
//

#import "SearchViewController.h"
#import "CloudButton.h"
#import "CloudView.h"
#import "BottomViewController.h"
#import "MainViewController.h"
@interface SearchViewController ()<CloudViewDelegate,UISearchBarDelegate>

{
    
}


@property (nonatomic, strong) UINavigationController *searchController;

@end

@implementation SearchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"搜索菜单";
    
    //self.view.backgroundColor = [UIColor clearColor];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 40, self.view.frame.size.width, self.view.frame.size.height - 148)];
    imageView.image = [UIImage imageNamed:@"CloudBG"];
    [self.view addSubview:imageView];

 
    CloudView *cloud = [[CloudView alloc] initWithFrame:CGRectMake(0, 40, self.view.frame.size.width, self.view.frame.size.height - 148)
                                           andNodeCount:40];
    
    cloud.delegate = self;
    [self.view addSubview:cloud];
    
    UISearchBar *searchbar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
    //searchbar.showsCancelButton = YES;
    searchbar.delegate = self;
    searchbar.placeholder = @"搜索你的美食";
    searchbar.showsCancelButton = YES;
    [self.view addSubview:searchbar];
    
}
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    [searchBar resignFirstResponder];
    MainViewController *mainController = [[MainViewController alloc] init];
    mainController.str = searchBar.text;
    [self.navigationController pushViewController:mainController animated:NO];
}
-(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
    [searchBar resignFirstResponder];
}

- (void)didSelectedNodeButton:(CloudButton *)button
{
    NSArray *array = @[@"面包",@"川菜",@"虾",@"蟹",@"披萨",@"寿司",@"鸡肉",@"鱼肉",@"面",@"羊肉",@"汉堡",@"排骨",@"丸子",@"包子",@"鸡蛋",@"蛋糕",@"扇贝",@"蛤蜊",@"蛋挞",@"三文鱼",@"养生",@"砂锅",@"甲鱼",@"火锅",@"鸭肉",@"驴肉",@"清蒸",@"红烧",@"酸",@"甜",@"苦",@"辣",@"炸",@"烤",@"爱心",@"海鲜",@"海参",@"刺身",@"减肥",@"补血"];
    BottomViewController *bottomView = [[BottomViewController alloc] init];
    bottomView.str = array[button.tag];
    [self.navigationController pushViewController:bottomView animated:YES];
   // NSLog(@"---%@",array[button.tag]);
}




////////////////////////////////////////////

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
